/*
** libmlx.c for  in /home/guicqu_g//rush/epikong/etape_1
** 
** Made by gallien guicquero
** Login   <guicqu_g@epitech.net>
** 
** Started on  Sat Mar 26 13:10:09 2011 gallien guicquero
** Last update Sat Mar 26 13:11:16 2011 gallien guicquero
*/

#include "mlx.h"
#include "window.h"

int	fill_img(t_i *i, int c)
{
  int	p;

  p = 0;
  while (p < (i->sy * i->sl) + (i->sx * (i->bpp >> 3)))
    {
      i->data[p] = (char) c & 0xFF;
      i->data[p + 1] = (char) (c >> 8) & 0xFF;
      i->data[p + 2] = (char) (c >> 16) & 0xFF;
      p += i->bpp >> 3;
    }
  return (0);
}

int	img_to_img(t_i *s, t_i *d, int xoff, int yoff)
{
  int	ps;
  int	pd;
  int	x;
  int	y;

  x = 0;
  while (x < s->sx)
    {
      y = 0;
      while (y < s->sy)
	{
	  ps = (y * s->sl) + (x * (s->bpp >> 3));
	  pd = ((y + yoff) * d->sl) + ((x + xoff) * (d->bpp >> 3));
	  d->data[pd] = s->data[ps];
	  d->data[pd + 1] = s->data[ps + 1];
	  d->data[pd + 2] = s->data[ps + 2];
	  ++y;
	}
      ++x;
    }
  return (0);
}

